package demo;
class Person {
    int age;
    String name;

    public Person(int age, String name) {
        this.age = age;
        this.name = name;
    }

    public boolean equals(Object obj) { //重写equals方法
        Person person = (Person) obj;
        if (this.name.equals(person.name) && this.age == person.age) { //String也重写了equals方法
            return true;
        }
        return false;
    }

    /*public int hashCode() {
        return Objects.hash(name, age);
    }*/
}

class Student{};

public class Test {

    public static void main(String[] args) {
        Person person = new Person(10, "bitch");
        Person person2 = new Person(10, "bitch");

        System.out.println(person.equals(person2));//Object类equals方法比较的是引用变量里存储的地址是否一样

        System.out.println(person.hashCode());
        System.out.println(person2.hashCode());//哈希值
    }

    //public static void func(Object obj) {} //Object 为所有类的默认父类
/*
    public static void main1(String[] args) {
        func(new Person());
        func(new Student());

    }
*/
}

abstract interface a { //默认是抽象修饰 不能是private final protected

}
